package com.stormrage.edu.serv.index.impl;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

import com.stormrage.edu.dao.index.IdxGuideDao;
import com.stormrage.edu.serv.index.IdxGuideServ;
import com.stormrage.entity.index.IdxGuide;
import com.stormragetech.core.exception.StormrageTechException;
import com.stormragetech.core.util.FileUtil;

/**
 * @Title: IdxGuideServImpl.java
 * @Package com.stormrage.edu.serv.Index.impl
 * @Description: 用户指南 Service
 * @author www.stormragetech.com
 * @date 2016年4月16日
 * @version V1.0
 */
@Service
public class IdxGuideServImpl implements IdxGuideServ {

	private static final Logger logger = LoggerFactory.getLogger(IdxGuideServImpl.class);

	@Autowired
	private IdxGuideDao idxGuideDao;

	@Override
	public void update(final IdxGuide arg0) throws StormrageTechException {

		logger.debug(" 【 Serv 】- 【 IdxGuideServ 】- 【 Update 】-【 STARTED 】");

		idxGuideDao.update(arg0);

		logger.debug(" 【 Serv 】- 【 IdxGuideServ 】- 【 Update 】-【 COMPLETED 】");

	}

	@Override
	public IdxGuide queryGuide() throws StormrageTechException {

		logger.debug(" 【 Serv 】- 【 IdxGuideServ 】- 【 QueryGuide 】-【 STARTED 】");

		IdxGuide entity = idxGuideDao.queryGuide();

		logger.debug(" 【 Serv 】- 【 IdxGuideServ 】- 【 QueryGuide 】-【 COMPLETED 】");
		return entity;

	}

	@Override
	public String upload(final MultipartFile arg0, final String arg1) throws StormrageTechException {

		logger.debug(" 【 Service 】- 【 AdminItemServ 】- 【 Upload 】- 【 STARTED 】");

		String fileName = null;

		fileName = FileUtil.saveFile(arg0, arg1, "image");

		// FileUtil.saveThumb(arg1 + fileName, arg1, fileName, 360);

		logger.debug(" 【 Service 】- 【 AdminItemServ 】- 【 Upload 】- 【 COMPLETED 】");
		return fileName;
	}

}
